<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr=['hug','red','pyy']
        // forEach 只遍历不返回，没有return
        arr.forEach(function( itme,index){
                 console.log(itme);//元素
                 console.log(index);//索引
        })


        const lis = [
            {
                id: '1',
                name: '研磨机',
                price: 100,
                picture: 'https://yanxuan-item.nosdn.127.net/84a59ff9c58a77032564e61f716846d6.jpg',
                count: 2,
            },
            {
                id: '2',
                name: '竹制品茶盘',
                price: 200,
                picture: 'https://yanxuan-item.nosdn.127.net/2d942d6bc94f1e230763e1a5a3b379e1.png',
                count: 3,

            },
            {
                id: '3',
                name: '莲花温酒器',
                price: 400,
                picture: 'https://yanxuan-item.nosdn.127.net/44e51622800e4fceb6bee8e616da85fd.png',
                count: 1,

            },
            {
                id: '4',
                name: '龙泉青瓷茶叶罐',
                price: 150,
                picture: 'https://yanxuan-item.nosdn.127.net/4356c9fc150753775fe56b465314f1eb.png',
                count: 1,
            }
        ]
            let a=0;
            lis.map(i => {
                console.log(i);
            const {price,count}=i
              a+= price*count
            });
            console.log(a);
            console.log('===========');

            let b=0
            lis.forEach(i => {
                console.log(i);
               const {price,count}=i
               b+= price*count
            });
           console.log(b);
    </script>
</body>
</html>